/**
 * @author  zhanshi Liu
 * @date    2020/08/12
 * @website www.jhmsona.cn
 */
let vm = new Vue({
    el:'#vm',
    data:{
        tableData: [],
        count:undefined,
        form:{
            loginName:undefined,
            ipaddr:undefined,
            limit:10,
            page:1,
        },
    },
    created:function (){
        this.getOnlineUser();
    },
    mounted:function(){
    },
    methods:{
        getOnlineUser(){
            axios.get('/sys/online/list', {
                params: {
                    data:JSON.stringify(this.form)
                }
            }).then(res => {
                this.tableData = res.data.data;
                this.count = res.data.count;
            }).catch(res=> {
                console.log(res);
            });
        },
        selectionChange(val){//多选
            this.userIds = val.map(item => item.userId);
        },
        search(){
            this.getOnlineUser();
        },
        reset(form1){
            this.$refs[form1].resetFields()
        },
        handleSizeChange(val) {
            this.form.limit = val;
            this.getOnlineUser();
        },
        handleCurrentChange(val) {
            this.form.page = val;
            this.getOnlineUser();
        },
        /**强退*/
        out(index,row){
            $.ajax({
                url:'/sys/online/forceLogout',
                type:'post',
                dataType:"json",
                data:{
                    sessionId:row.sessionId
                },
                success:res =>{
                    if(res.code==500){
                        this.$notify({
                            title: '警告',
                            message: res.msg,
                            type: 'warning'
                        });
                    }else{
                        this.getOnlineUser();
                        this.$notify({
                            title: '成功',
                            message: res.msg,
                            type: 'success'
                        });

                    }
                }
            })
        },
        exportData(){
            console.log("导出数据......")
        }

    }
})

